/**
 * 数组扁平化
 * @param tree 
 * @returns 
 */
const flatten = (tree: any, key: string) => {
    return tree.reduce((item: any, next: any) => {
      return item.concat(Array.isArray(next[`${key}`]) ? flatten(next[`${key}`], key): next )
    }, [])
}

export default flatten;